<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');


//get num_rows currently in buildings table

$building_id = mysql_real_escape_string(strip_tags($_GET['bid']));

$get_building_data = mysql_query("SELECT * FROM buildings WHERE id = $building_id");
$building_name = mysql_result($get_building_data,0,'building_name');
$abbreviation = mysql_result($get_building_data,0,'abbreviation');

echo "<p>";
	echo "<a href='index.php?id=$building_id'>&lt;&lt; Back to Classrooms Portal</a><br />";
echo "</p>";
echo "<h1>Add Classroom in $building_name</h1>";

//counting variable
$i = 0;

$query="SELECT * FROM classroom_types";
$result=mysql_query($query);

//determine dynamically number of rows read from table
$num_rows=mysql_numrows($result);


$classroom_type_id = 1;

echo "<form action='add_do.php' method='post'>";

//start table
echo "<table border='0'>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Room Number</b></td>";
		echo '<td><input type="text" name="room_num"></td>';
	echo "</tr>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Seating Capacity</b></td>";
		echo '<td><input type="text" name="num_seats"></td>';
	echo "</tr>";
	
	echo "<tr>";
		echo "<td><b>Classroom Type</b></td>";
		echo "<td>";
			echo "<select name='type'>";
				while ($i < $num_rows)
				{
					$type_description=mysql_result($result,$i,"description");
					$type_id=mysql_result($result,$i,"id");
					echo "<option value='$type_id'>$type_description</option>";
					$i++;
				}
			echo "</select>";
	echo "</tr>";


//end table tag
echo "</table>";

echo "<input type='hidden' name='bid' value='$building_id'>";
echo '<p><input type="submit"></p>';
echo '</form>';



echo '<h2>OR</h2>';

echo "<form action='add_type.php' method='post'>";

//start table
echo "<table border='0'>";

	//create table row
	echo "<tr>";
		echo "<td><b>Add Classroom Type: </b></td>";
		echo "<td><input type='text' name='new_type'></td>";
	echo "</tr>";

//end table tag
echo "</table>";

echo "<input type='hidden' name='bid' value='$building_id'>";
echo '<p><input type="submit"></p>';
echo '</form>';

;

?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>